package data_structure;

public class leetcode_0383 {
    public boolean canConstruct(String ransomNote, String magazine) {
        char[] char1=magazine.toCharArray();
        char[] list=ransomNote.toCharArray();
        int len1=char1.length;
        int len2=list.length;
        int [] alpha=new int[26];
        for(int i=0;i<len1;++i){
            alpha[char1[i]-'a']+=1;
        }
        for(int i=0;i<len2;++i){
            alpha[list[i]-'a']-=1;
            if(alpha[list[i]-'a']<0) return false;
        }
        return true;
    }
}
